//$(document).ready(function(){
	$.ajaxSetup({
		type: "POST",
		cache: false
	});


	//学院专业的二级联动
	function f_change_col_pro(mainop,subop)
	{
		if (mainop == null || subop == null) return;
		subop.options.length = 0;
		subop.options[subop.length] = new Option("请选择", "");

		if (mainop.value > 0)
		{
			var i;
			for (i=0;i < col_pro_list.length; i++)
			{
				if (col_pro_list[i][2] == mainop.value && col_pro_list[i][0] != mainop.value)
				{
					subop.options[subop.length] = new Option(col_pro_list[i][1], col_pro_list[i][0]);
				}
			}
		}
	}
	
	function convert_birthday(birthday) {
		birthday = birthday[0] + birthday[1] + birthday[2] + birthday[3] + "年"
			+ birthday[4] + birthday[5] + "月"
				+ birthday[6] + birthday[7] + "日";
		return birthday;
	}
	
	$("#list p").live("click", function() {
		if ($(this).next().attr("href") && $(this).next().attr("href") != 'javascript:void(0);') {
			var href = $(this).next().attr("href");
			location.assign(href);
		} else {
			$(this).next().trigger("click");
		}
	});
	$("#list p").live("mouseover", function() {
		if ($(this).next().attr("title")) {
			$(this).attr("title", $(this).next().attr("title"));
		} else {
			$(this).attr("title", $(this).next().html());
		}
		
	});
	
	function manage_employee_search_change() {
		input_a_name = ($("#name").val() != 0) ? $("#name").val() : 0;
		select_a_gender = ($("#gender").val() != 0) ? $("#gender").val() : 0;
		select_a_category = ($("#category").val() != 0) ? $("#category").val() : 0;
		select_a_col = ($("#col").val() != 0) ? $("#col").val() : 0;
		select_a_pro = ($("#pro").val() != 0) ? $("#pro").val() : 0;
		
		window.location.href = "/index.php/backend/association/employee/manage/" +  input_a_name + "-" + select_a_gender + "-" + select_a_category + "-" + select_a_col + "-" + select_a_pro;
	}
	
	$("#announcement a").live("click", function() {
		var id = $(this).attr('id');
		var category = $(this).attr('class');
		ajax_get_announcement(id, category);
	});
	
	function ajax_get_announcement(id, category) {
		$("#show_announcement_dialog").dialog('open');
		$("#show_announcement_dialog").children().children().empty();
		$("#show_announcement_dialog").spin();
		$.ajax({
			url: "/index.php/frontend/" + category + "/ajax_announcement_detail",
			dataType: 'json',
			data: {id: id, category: category},
			success: function(data) {
				$("#show_announcement_dialog").spin(false);
				$("#show_announcement_dialog #title").html(data.title);
				$("#show_announcement_dialog #contents").html(data.contents);
				$("#show_announcement_dialog #author").html(data.author.name);
				$("#show_announcement_dialog #author").attr("href", data.author.href);
				$("#show_announcement_dialog #author").attr("title", data.author.title);
				$("#show_announcement_dialog #publish_time").html(data.create_time);
				$("#show_announcement_dialog #prev").val(data.nearest_id.prev_id);
				$("#show_announcement_dialog #next").val(data.nearest_id.next_id);
				$("#show_announcement_dialog #category").val(category);
			}
		});
	}
//});